import random
import time
class BucketSort():
    def __init__(self) -> None:
        self.count = 0
    
    def sort(self,ls):
        ans = []
        maxnum = max(ls)
        minnum = min(ls)
        bucket = [0]*(maxnum-minnum+1)
        for i in range(len(ls)):
            # print(i)
            bucket[ls[i]-minnum]+=1
        for i in range(len(bucket)):
            while(bucket[i]!=0):
                ans.append(i+minnum)
                bucket[i]-=1
        return ans
       
    def isSorted(self,ls):
        # 判断是否有序
        for i in range(1,len(ls)):
            if ls[i]<ls[i-1]:
                return False
        return True
